package com.acoffee.java;


import org.junit.Test;

import javax.annotation.Resources;
import java.io.IOException;
import java.io.InputStream;
import java.time.Period;
import java.util.Properties;

/**
 * @author acoffee
 * @create 2021-11-09 16:11
 */
public class ThridFactory {

    public Person doPerson(){
        Properties properties = new Properties();
        Person person = null;
        InputStream is = this.getClass().getResourceAsStream("doPerson.properties");
        try {
            properties.load(is);

             person = (Person)Class.forName(properties.getProperty("person")).newInstance();

        } catch (Exception e) {
            e.printStackTrace();
        }

        try {
            is.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        properties.clear();
        return person;
    }

    @Test
    public void testPerson(){
        ThridFactory thridFactory = new ThridFactory();
        Person person = thridFactory.doPerson();
        person.eat();
    }

}
